package com.demo.activitylife;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import androidx.appcompat.app.AppCompatActivity;

public class FirstActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.first);

//        TextView txtView=(TextView)findViewById(R.id.textView1);
//        txtView.setText("Activity:"+this.getLocalClassName()+"\nTaskId:"+this.getTaskId());
        //输出日志
        Log.i("my_debug", "-------First-->onCreate()------");
        Button btn = (Button) findViewById(R.id.btn);
//		btn.setText("Close");
        //为bn按钮绑定事件监听器
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View source) {
                //结束该Activity
//				FirstActivity.this.finish();
                // 启动第二个Activity
                Intent intent = new Intent(FirstActivity.this, SecondActivity.class);
                FirstActivity.this.startActivity(intent);
            }
        });
    }

    @Override
    public void onStart() {
        super.onStart();
        //输出日志
        Log.i("my_debug", "-------First-->onStart()------");
    }

    @Override
    public void onRestart() {
        super.onRestart();
        //输出日志
        Log.i("my_debug", "-------First-->onRestart()------");
    }

    @Override
    public void onResume() {
        super.onResume();
        //输出日志
        Log.i("my_debug", "-------First-->onResume()------");
    }

    @Override
    public void onPause() {
        super.onPause();
        //输出日志
        Log.i("my_debug", "-------First-->onPause()------");
    }

    @Override
    public void onStop() {
        super.onStop();
        //输出日志
        Log.i("my_debug", "-------First-->onStop()------");
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        //输出日志
        Log.i("my_debug", "-------First-->onDestroy()------");
    }
}
